﻿using System;
using System.Collections;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WCF = System.Web.Configuration.WebConfigurationManager;

/// <summary>
/// Summary description for SanPhamDauGia_Data
/// </summary>
public class SanPhamDauGia_Data
{
    public void insert()
    { 
    
    }

    public void update()
    { 
    
    }

    public void delete()
    { 
    
    }

    public void search_all()
    { 
    
    }

    public SqlDataAdapter DanhSachSanPhamDauGiaVoiDanhMuc(int MaDanhMucPhu)
    {
        string connectionString = WCF.ConnectionStrings["gets_SPDG"].ConnectionString;
        SqlConnection connection = new SqlConnection(connectionString);
        if (connection.State == ConnectionState.Open)
            connection.Close();
        connection.Open();
        SqlDataAdapter adapter = new SqlDataAdapter();
        try
        {
            SqlCommand Command = new SqlCommand();
            Command.CommandText = "DanhMucSanPhamTheoDanhMucPhu";
            Command.Connection = connection;
            Command.CommandType = CommandType.StoredProcedure;
            Command.Parameters.AddWithValue("@MaDanhMucPhu", MaDanhMucPhu);
            adapter.SelectCommand = Command;
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        return adapter;
    }

    public SqlDataAdapter DanhSachSanPhamDauGia()
    {
        string connectionString = WCF.ConnectionStrings["gets_SPDG"].ConnectionString;
        SqlConnection connection = new SqlConnection(connectionString);
        if (connection.State == ConnectionState.Open)
            connection.Close();
        connection.Open();
        SqlDataAdapter adapter = new SqlDataAdapter();
        try
        {
            SqlCommand Command = new SqlCommand();
            Command.CommandText = "get_DanhMucSanPham";
            Command.Connection = connection;
            Command.CommandType = CommandType.StoredProcedure;            
            adapter.SelectCommand = Command;
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        return adapter;
    }

    public SqlDataAdapter SanPhamDauGia(int Ma)
    {
        string connectionString = WCF.ConnectionStrings["gets_SPDG"].ConnectionString;
        SqlConnection connection = new SqlConnection(connectionString);
        if (connection.State == ConnectionState.Open)
            connection.Close();
        connection.Open();
        SqlDataAdapter adapter = new SqlDataAdapter();
        try
        {
            SqlCommand Command = new SqlCommand();
            Command.CommandText = "test";
            Command.Connection = connection;
            Command.CommandType = CommandType.StoredProcedure;
            Command.Parameters.AddWithValue("@Ma", Ma);
            adapter.SelectCommand = Command;
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        return adapter;
    }
 
}
